package com.myjpa.common.web;

import lombok.Getter;
import lombok.Setter;

/**
 * @author: yaoll
 * @date: 2020-09-04
 * @verison: 1.0
 */
public class BaseResponse<T> {

	public static final String SUCCESS = "success";
	public static final String FAIL = "fail";
	public static final String EXCEPTION = "exception";

	@Getter
	@Setter
	private String result;

	@Getter
	@Setter
	private String message;

	@Getter
	@Setter
	protected T data;

	public void setFail(String message) {
		setResult(FAIL);
		setMessage(message);
	}

	public BaseResponse() {
		super();
		this.result = SUCCESS;
	}

	public BaseResponse(String result, String message) {
		super();
		this.result = result;
		this.message = message;
	}

	public boolean success() {
		return SUCCESS.equals(this.result);
	}

}
